package com.decent.ejfadmin.product.dao.provider;

import org.apache.commons.lang3.StringUtils;

import java.util.HashMap;
import java.util.Objects;

/**
 * describe:
 *
 * @author JunLei He
 * @date 2018年07月11日
 */
public class SupplyProductProvider {


    /**
     * 查询产品信息
     *
     * @param params 参数集
     * @return 返回SQL语句
     */
    public String queryProduct(HashMap<String, Object> params) {
        StringBuffer sql = new StringBuffer();
        sql.append(" SELECT   " +
                " p.state,   " +
                " p.area,   " +
                " p.face,   " +
                " p.product_type productType,   " +
                " p.id productId   " +
                "FROM   " +
                " yuhuang_supply_product p   " +
                "WHERE  p.product_type=#{productType}  ");
        if (StringUtils.isNotBlank((String) params.get("area"))) {
            sql.append(" and   p.area=#{area} ");
        }
        if (Objects.nonNull(params.get("face"))) {
            sql.append(" AND p.face=#{face} ");
        }
        return sql.toString();
    }
}
